<?php
require_once("lib/simplepie/simplepie.php");
require_once("models/item.php");
require_once("models/feed.php");

class ReaderController extends Controller
{
	/**
	 * Main screen. Shows all feeds & new unread msgs.
	 */
	function index()
	{
		$unreads = Item::getUnreadItemsForUsername("Ives");
		$this->template->unreads = $unreads;
		$this->template->feeds = Feed::getFeedsForUser("Ives");
	 	$this->template->render("index.html.tpl");
	}


	/**
	 * POST function that will be called when a feed is to be added.
	 * TODO: Make post only...
	 */
	function add($url)
	{
		$f = Feed::add($url);
		$f->retreiveFeed();

		$this->index();
	}

	/**
	 * Shows posts for one specific feed. 
	 */
	function feed($id)
	{
		//$this->template->unreads = Item::getItemsInFeed($id);
		$this->template->feeds = Feed::getFeedsForUser("Ives");
	 	$this->template->render("index.html.tpl");
	}
}

?>
